/*
 * Copyright 2011 Clean GWT
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package com.cleangwt.bootstrap.client.style;

import com.google.gwt.user.client.ui.Widget;

/**
 * This class provides bootstrap buttton styles and methods to set it.
 * 
 * @author Jess
 * @version 1.0
 * @since 1.0
 */
public class Btn {
  /**
   * The button base style
   */
  public static String BTN_STYLE = "btn";
  /**
   * The base style
   */
  public static String DEFAULT_STYLE = "btn-default";
  /**
   * The base style
   */
  public static String PRIMARY_STYLE = "btn-primary";
  /**
   * The base style
   */
  public static String SUCCESS_STYLE = "btn-success";
  /**
   * The base style
   */
  public static String WARNING_STYLE = "btn-warning";
  /**
   * The base style
   */
  public static String DANGER_STYLE = "btn-danger";
  /**
   * The base style
   */
  public static String INFO_STYLE = "btn-info";
  /**
   * The base style
   */
  public static String LINK_STYLE = "btn-link";

  /**
   * The addon style
   */
  public static String BLOCK_STYLE = "btn-block";
  /**
   * The size style
   */
  public static String LG_STYLE = "btn-lg";
  /**
   * The size style
   */
  public static String SM_STYLE = "btn-sm";
  /**
   * The size style
   */
  public static String XS_STYLE = "btn-xs";

  /**
   * The button group base style
   */
  public static String BTN_GROUP_STYLE = "btn-group";

  /**
   * Sets the style name with base {@link #BTN_STYLE} for the given widget.
   * 
   * @param style the base style
   * @param widget the widget
   * @return the widget itself
   */
  public static Widget style(String style, Widget w) {
    assert style != null : "Stye must not be null.";
    w.setStyleName(BTN_STYLE + " " + style);
    return w;
  }

  /**
   * Sets {@link #BLOCK_STYLE} with base button style for the given widget.
   * 
   * @param w the widget
   * @return the widget itself
   */
  public static Widget block(Widget w) {
    w.addStyleName(BLOCK_STYLE);
    return w;
  }

  /**
   * Sets {@link #DEFAULT_STYLE} with base {@link #BTN_STYLE} for the given widget.
   * 
   * @param widget the widget
   * @return the widget itself
   */
  public static Widget style(Widget w) {
    return style(DEFAULT_STYLE, w);
  }

  /**
   * Sets {@link #PRIMARY_STYLE} with base {@link #BTN_STYLE} for the given widget.
   * 
   * @param widget the widget
   * @return the widget itself
   */
  public static Widget primary(Widget w) {
    return style(PRIMARY_STYLE, w);
  }

  /**
   * Sets {@link #INFO_STYLE} with base {@link #BTN_STYLE} for the given widget.
   * 
   * @param widget the widget
   * @return the widget itself
   */
  public static Widget info(Widget w) {
    return style(INFO_STYLE, w);
  }

  /**
   * Sets {@link #SUCCESS_STYLE} with base {@link #BTN_STYLE} for the given widget.
   * 
   * @param widget the widget
   * @return the widget itself
   */
  public static Widget success(Widget w) {
    return style(SUCCESS_STYLE, w);
  }

  /**
   * Sets {@link #WARNING_STYLE} with base {@link #BTN_STYLE} for the given widget.
   * 
   * @param widget the widget
   * @return the widget itself
   */
  public static Widget warning(Widget w) {
    return style(WARNING_STYLE, w);
  }

  /**
   * Sets {@link #DANGER_STYLE} with base {@link #BTN_STYLE} for the given widget.
   * 
   * @param widget the widget
   * @return the widget itself
   */
  public static Widget danger(Widget w) {
    return style(DANGER_STYLE, w);
  }

  /**
   * Sets {@link #LINK_STYLE} with base {@link #BTN_STYLE} for the given widget.
   * 
   * @param widget the widget
   * @return the widget itself
   */
  public static Widget link(Widget w) {
    return style(LINK_STYLE, w);
  }

  /**
   * Adds {@link #LG_STYLE} to the given widget and remove other size related style.
   * 
   * @param widget the widget
   * @return the widget itself
   */
  public static Widget lg(Widget w) {
    w.removeStyleName(SM_STYLE);
    w.removeStyleName(XS_STYLE);
    w.addStyleName(LG_STYLE);
    return w;
  }

  /**
   * Adds {@link #SM_STYLE} to the given widget and remove other size related style.
   * 
   * @param widget the widget
   * @return the widget itself
   */
  public static Widget sm(Widget w) {
    w.removeStyleName(LG_STYLE);
    w.removeStyleName(XS_STYLE);
    w.addStyleName(SM_STYLE);

    return w;
  }

  /**
   * Adds {@link #XS_STYLE} to the given widget and remove other size related style.
   * 
   * @param widget the widget
   * @return the widget itself
   */
  public static Widget xs(Widget w) {
    w.removeStyleName(LG_STYLE);
    w.removeStyleName(SM_STYLE);
    w.addStyleName(XS_STYLE);
    return w;
  }

}
